package com.computercourse.ucenter.controller;

import com.computercourse.api.ucenter.UcenterControllerApi;
import com.computercourse.framework.domain.ucenter.ext.CicUserExt;
import com.computercourse.framework.domain.ucenter.response.ModifyUserResult;
import com.computercourse.ucenter.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author Feng.Yuan
 * @description
 * @date 2020/2/1 5:14 下午
 * @return
 */
@RestController
@RequestMapping("/ucenter")
public class UcenterController implements UcenterControllerApi {

    @Autowired
    private UserService userService;

    @Override
    @GetMapping("/getuserext")
    public CicUserExt getUserext(@RequestParam("username") String username) {
        return userService.getUserExt(username);
    }

    @Override
    @PostMapping("/modify/name/{userName}/{id}")
    public ModifyUserResult modifyUserName(@PathVariable("userName") String userName, @PathVariable("id") String id) {
        return userService.modifyUserName(userName, id);
    }

    @Override
    @PostMapping("/modify/phone/{userPhone}/{id}")
    public ModifyUserResult modifyUserPhone(@PathVariable("userPhone") String userPhone, @PathVariable("id") String id) {
        return userService.modifyUserPhone(userPhone, id);
    }

    @Override
    @PostMapping("/modify/password/{userPassword}/{id}")
    public ModifyUserResult modifyUserPassword(@PathVariable("userPassword") String userPassword, @PathVariable("id") String id) {
        return userService.modifyUserPassword(userPassword, id);
    }

    @Override
    @PostMapping("/modify/email/{userEmail}/{id}")
    public ModifyUserResult modifyUserEmail(@PathVariable("userEmail") String userEmail, @PathVariable("id") String id) {
        return userService.modifyUserEmail(userEmail, id);
    }

    @Override
    @PostMapping("/modify/qq/{userQQ}/{id}")
    public ModifyUserResult modifyUserQQ(@PathVariable("userQQ") String userQQ, @PathVariable("id") String id) {
        return userService.modifyUserQQ(userQQ, id);
    }

    @Override
    @PostMapping("/upload/user/image/")
    public ModifyUserResult uploadUserImage(MultipartFile multipartFile, String id) throws Exception{
        return userService.uploadUserImage(multipartFile, id);
    }
}
